package cn.edu.zafu.bigdata.lb;
/**
 * @author LiuBo
 * 自定义异常类
 */
class InvalidScoreException extends Exception {
    public InvalidScoreException(String errorMessage) {
        super(errorMessage);
    }
}
/**
 * @author LiuBo
 * 静态方法用于检查分数是否有效
 */
class ScoreChecker {
    public static void checkScore(int score) throws InvalidScoreException {
        if (score < 0 || score > 100) {
            throw new InvalidScoreException("分数无效：必须在0到100之间。");
        } else {
            System.out.println("分数有效：输入的分数是 " + score);
        }
    }
    public static void main(String[] args) {
        java.util.Scanner scanner = new java.util.Scanner(System.in);

        try (scanner) {
            System.out.println("请输入分数：");
            int score = scanner.nextInt();
            checkScore(score);
        } catch (InvalidScoreException e) {
            System.out.println(e.getMessage());
        }
    }
}